﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1.session
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //判断session
            if (Session["User"] != null)
            {
                Label1.Text = "欢迎你：" + Session["User"];
            }
            else
            {
                Response.Write("<script>alert('请先登录');window.location.href('login.aspx')</script>");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Response.Redirect("login.aspx");
        }
    }
}